<!--#Include File="conn.asp" -->
<!--#Include File="manager/comm/inc.asp" -->
<html>
<head>
<title>在线投稿</title>
<meta http-equiv="Content-Language" content="zh-CN">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link href="manager/images/admin.css" type=text/css rel=stylesheet>
<LINK href="manager/images/base.css" rel=StyleSheet>
<SCRIPT language=JavaScript src="manager/images/base.js" type=Text/JavaScript></SCRIPT>
</head>
<body text="#000000">

<SCRIPT language=JavaScript>
function checkData() {
	var f1=document.a1;
	var wm="";
	var noerror = 1;


	var t1 = a1.Column;


	var t1 = a1.title;
	if (t1.value == "" || t1.value == " ") {
		wm += "请填写文章的标题\r\n";
		noerror = 0;
	}
	
	var sHTML = f1.content.value;
	if (sHTML == "" ) {
		wm += "请填写文章的正文\r\n";
		noerror = 0;
	}
	
	var name = a1.name;
	if (name.value == "" || name.value == " ") {
		wm += "请填写文章作者\r\n";
		noerror = 0;
	}
	
	var email = a1.email;
	if (email.value == "" || email.value == " ") {
		wm += "请填写作者联系方式\r\n";
		noerror = 0;
	}
	
	if (noerror == 0) {
		alert(wm);
	}
	else{
		document.a1.Submit1.value ="正在提交，请稍候...";
		document.a1.Submit1.disabled=true;
		f1.submit();
	}
	return false;
} 
</SCRIPT>
<%
Dim Atcion
Atcion=Request.QueryString ("atcion")

Select Case LCase(Atcion)
Case "save"
	Call Save
end select

Sub Save
	Call EA_Pub.Chk_Post
	
	Dim Title,Author,Text,KeyWord,ColumnId,ColumnName,ColumnCode,Byter,TColor,IsImg,ImgPath,IsTop,IsDis,OutUrl,IsOut,AuthorId,CutArticle,ViewNum,AddDate,IsPass,Source,SourceUrl,Summary
	Dim PostId,TempStr,TrueTime,IsSaveAs
	Dim Key,i
	
	If Request.Form("column")="" Or Request.Form("column")="0" Then 
		ErrMsg=str_PassDataError
		Call EA_Manager.Error(1)
	End If
	
	FoundErr=False
	
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)
	Title=EA_Pub.SafeRequest(2,"title",1,"",1)
	Author=EA_Pub.SafeRequest(2,"name",1,"",1)
	Text = EA_Pub.SafeRequest(2,"content",1,"",1)

	KeyWord=""
	TempStr=Split(Request.Form ("Column"),"|||")
	ColumnId=EA_Pub.SafeRequest(0,Trim(TempStr(0)),0,0,0)
	ColumnName=EA_Pub.SafeRequest(0,Trim(TempStr(1)),1,"",1)
	ColumnCode=EA_Pub.SafeRequest(0,Trim(TempStr(2)),1,"",0)
	TColor=0
	ImgPath=""
	IsTop=0
	OutUrl=""
	AuthorId=0
	CutArticle="0|0"
	ViewNum=0
	AddDate=Now()
	IsPass=0
	Source="在线投稿"
	SourceUrl=""
	Summary=""
	IsSaveAs=0
	Byter=Lenb(Text)
	CutArticle=Replace(CutArticle," ","")
	CutArticle=Replace(CutArticle,",","|")

	If Len(Title)>150 Or Len(Title)=0 Then 
		ErrMsg="标题内容长度不符。"
		ErrMsg=ErrMsg&"<li>大于150或者等于0个字符"
		FoundErr=True
	End If
	If Len(Author)>16 Then 
		ErrMsg="作者长度不符。"
		ErrMsg=ErrMsg&"<li>大于16个字符"
		FoundErr=True
	ElseIf Len(Author)=0 then 
		Author="本站编辑"
	End If
	If Len(KeyWord)>20 Then 
		ErrMsg="关键字长度不符。"
		ErrMsg=ErrMsg&"<li>大于20个字符"
		FoundErr=True
	End If
	If Len(Summary)>250 Then 
		ErrMsg="文章简介长度不符。"
		ErrMsg=ErrMsg&"<li>大于250个字符"
		FoundErr=True
	End If
	
	If FoundErr Then Call EA_Manager.Error(1)
	
	If OutUrl="" Then 
		IsOut=0
	Else
		IsOut=1
	End If
	If ImgPath="" Then 
		IsImg=0
	Else
		IsImg=1
	End If
	
	TrueTime=Year(CDate(AddDate))
	TrueTime=TrueTime&Right("00"&Month(CDate(AddDate)),2)
	TrueTime=TrueTime&Right("00"&Day(CDate(AddDate)),2)
	TrueTime=TrueTime&Right("00"&Hour(CDate(AddDate)),2)
	TrueTime=TrueTime&Right("00"&Minute(CDate(AddDate)),2)
	TrueTime=TrueTime&Right("00"&Second(CDate(AddDate)),2)
	
	Randomize Timer
	key="000000"&Cstr(Int((999999-1+100000)*Rnd+1))
	TrueTime=TrueTime&Right(Key,6)

	IsDis=EA_DBO.Get_Column_Info(ColumnId)(11,0)

	If Rs.State=1 Then rs.Close
	If PostId<>0 Then
		Sql="Select * From [NB_Content] Where [Id]="&PostId
		rs.Open Sql,Conn,2,2
	Else
		rs.Open "SELECT * FROM [NB_Content] WHERE 0=1",Conn,2,2
		rs.AddNew
	End If
		rs("title")=Title
		rs("author")=Author
		rs("authorid")=AuthorId
		rs("Content")=Text&" "
		rs("KeyWord")=KeyWord
		rs("ColumnId")=ColumnId
		rs("ColumnName")=ColumnName
		rs("ColumnCode")=ColumnCode
		rs("byte")=Byter
		rs("tcolor")=TColor
		rs("isimg")=IsImg
		rs("img")=ImgPath
		rs("istop")=IsTop
		rs("IsDis")=IsDis
		rs("outurl")=OutUrl
		rs("isout")=IsOut
		rs("CutArticle")=CutArticle
		rs("ViewNum")=ViewNum
		rs("AddDate")=AddDate
		rs("IsPass")=IsPass
		rs("Source")=Source
		rs("SourceUrl")=SourceUrl
		rs("Summary")=Summary
		rs("TrueTime")=TrueTime
		rs.update
	Rs.Close:Set Rs=Nothing

	If PostId=0 Then 
		If IsPass=0 Then 
			If iDataBaseType<>2 Then EA_DBO.Set_System_ManagerTopicTotal 1

			EA_DBO.Set_Column_ManagerTopicTotal ColumnId,1
		Else
			If iDataBaseType<>2 Then EA_DBO.Set_System_TopicTotal 1

			EA_DBO.Set_Column_TopicTotal ColumnId,1
		End If
	End If

	Application.Lock 
	Application(sCacheName&"IsFlush")=1
	Application.UnLock 
	
	Call EA_Pub.Close_Obj
	Set EA_Pub=Nothing
	response.write "<script>alert('在线投稿成功!')</script>"
	response.Write "<script>window.location = 'index.asp';</script>"
End Sub
%>
<table width="98%" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td height="5"></td>
  </tr>
  <tr>
    <td><FIELDSET>
      <LEGEND><SPAN id=help_topic_icon onclick=sw_help_topic()>操作说明</SPAN></LEGEND>
      <DIV id=help_topic>如果该文章包含图片请发到邮箱tw@znufe.edu.cn,并注明标题. </DIV>
      </FIELDSET></td>
  </tr>
</table>
<br>
<table width="98%" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td><FIELDSET>
      <LEGEND>添加文章</LEGEND>
      <table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
        <form name=a1 method="post" action="?atcion=save&postID=" onSubmit="return checkData()">
          <input type=hidden name="authorid" value="0">
          <tr valign="middle" height="25">
            <td width="10%" align="right"><font color=800000><u>所属栏目</u></font>&nbsp;</td>
            <td width="50%" align="left">&nbsp;
            <%  
			 dim Temp
			 dim ColumnList
			 Temp =EA_DBO.Get_Column_List()
	If IsArray(Temp) Then
		dim i
		For i=0 To UBound(Temp,2)
			If true Then
				dim Level
				Level		= (Len(Temp(2,i))/4-1)*3
				ColumnList	= ColumnList & "<option value=""" & Temp(0,i) & "|||" & Temp(1,i) & "|||" & Temp(2,i) & """"
				
				
				
				ColumnList	= ColumnList & ">"
				ColumnList	= ColumnList & "├"
				ColumnList	= ColumnList & String(Level,"-")
				ColumnList	= ColumnList & Temp(1,i) & ""
				
					
				ColumnList	= ColumnList & "</option>"
			End If
		Next
		Response.Write "<select name=""Column"">"&ColumnList&"</select>"
	End If
	%>
              <font color=red>*</font></td>
			<td width="10%" align="right">&nbsp;</td>
            <td align="left">&nbsp;
            &nbsp;</td>
          </tr>
          <tr valign="middle" height="25">
            <td align="right"><font color=800000><u>文章标题</u></font>&nbsp;</td>
            <td align="left" colspan="3">&nbsp;&nbsp;
              <input name="title" type="text" size=50 value="">
            <font color=red>*</font></td>
          </tr>
		   <tr valign="middle" height="25">
            <td align="right"><font color=800000><u>作者姓名</u></font>&nbsp;</td>
            <td align="left">&nbsp;&nbsp;
              <input name="name" type="text" size=50 value="">
            <font color=red>*</font></td>
			 <td align="right"><font color=800000><u>联系方式</u></font>&nbsp;</td>
            <td align="left">&nbsp;&nbsp;
              <input name="email" type="text" size=50 value="">
            <font color=red>*</font></td>
          </tr>
		  <tr valign="middle" height="25">
            <td align="right"><font color=800000><u>文章正文</u></font>&nbsp;</td>
            <td align="left" colspan="3"></td>
          </tr>
          <tr valign="middle" >
            <td colspan="4"><table width="100%">
                <tr valign="middle" height="25">
                  <td><label>
                    <textarea name="content" cols="160" rows="25" id="content"></textarea>
                  </label> <font color=red>*</font></td>
                </tr>
              </table></td>
          </tr>
         
          <tr height="30">
            <td valign="middle" colspan="4">&nbsp;
              <input class="smb_btn" type="submit" name="Submit1" value="保 存" id="Submit1">&nbsp;
              <input class="smb_btn" type="reset" name="Submit2" value="清 除"></td>
          </tr>
        </form>
      </table>
      </FIELDSET></td>
  </tr>
</table>
<br>

